<template>
	<view class="treaty">
		<u-popup :show="isShow" :round="10" mode="center" @close="treatyclose">
			<view class="popup">
				<text class="titles">{{title}}</text>
				<scroll-view scroll-y class="popup-cont">
					<rich-text :nodes="dHtml"></rich-text>
				</scroll-view>
				<view class="operation">
					<view class="close" @click="treatyclose">取消</view>
					<view class="show" @click="treatyopen">确认</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>
<script>
	import graceRichText from '@/utils/rich-text.js'
	export default {
		props: {
			title: {
				type: String,
				default: '服务协议'
			},
			content: {
				type: String,
				default: ''
			}
		},
		data() {
			return {
				dHtml: '', // 富文本或文本域内容
				isShow: false, //悬浮窗显示
			}
		},
		methods: {
			show() {
				this.dHtml = graceRichText.format(this.content)
				this.isShow = true
			},
			hide() {
				this.treatyclose()
			},
			treatyopen() { //确认
				this.isShow = false
				this.$emit('confirm')
			},
			treatyclose() { //取消
				this.isShow = false
				this.$emit('close')
			}
		}
	}
</script>

<style lang="scss" scoped>
	.popup {
		padding: 40rpx;
		display: flex;
		flex-direction: column;
		align-items: center;

		.titles {
			font-size: 32rpx;
			font-weight: 600;
			color: #333333;
		}

		.popup-cont {
			width: 540rpx;
			height: 726rpx;
			margin: 20rpx 0;
			font-size: 24rpx;
			font-weight: 400;
			color: #333333;
			overflow: scroll;
		}

		.operation {
			width: 100%;
			display: flex;
			justify-content: space-between;
			align-items: center;

			view {
				font-size: 28rpx;
				font-weight: 400;
				color: #FFFFFF;
				display: flex;
				justify-content: center;
				align-items: center;
			}

			.close {
				width: 182rpx;
				height: 72rpx;
				background-color: $uni-color-error;
				border-radius: 60rpx;
			}

			.show {
				width: 334rpx;
				height: 72rpx;
				background-color: $uni-color-primary;
				border-radius: 60rpx;
			}
		}
	}
</style>
